var address_li = document.getElementsByClassName("address")[0].getElementsByTagName("li");
var del0 = address_li[0].childNodes[8];
var edit0 = address_li[0].childNodes[10];
var editColor0 = edit0.getElementsByTagName("a")[0];
address_li[0].style.backgroundColor = "#c6474e";
address_li[0].style.color = "#fff";
del0.style.display = "none";
edit0.style.display = "block";
editColor0.style.color = "#fff";

for (var i = 0; i < (address_li.length - 1); i++) {
	address_li[i].onclick = function() {
		clear();
		var del = this.childNodes[8];
		var edit = this.childNodes[10];
		var dis = getComputedStyle(del);
		if (dis.display == "block") {
			this.style.backgroundColor = "#c6474e";
			this.style.color = "#fff";
			del.style.display = "none";
			edit.style.display = "block";
			var editColor = edit.getElementsByTagName("a")[0];
			editColor.style.color = "#fff";
		} else {
			this.style.backgroundColor = "#f1efef";
			this.style.color = "#666666";
			del.style.display = "block";
			edit.style.display = "none";
		}

	}
}

function clear(){
	for (var i = 0; i < address_li.length -1; i++) {
		var del = address_li[i].childNodes[8];
		var edit = address_li[i].childNodes[10];
		address_li[i].style.backgroundColor = "#f1efef";
		address_li[i].style.color = "#666666";
		del.style.display = "block";
		edit.style.display = "none";
	}
}

function del(obj){
	var par = obj.parentNode.parentNode;
	par.remove();
}

function edit(obj){
	var p = obj.parentNode.parentNode.childNodes[1];
	p.setAttribute("contenteditable","true");
	p.focus();
	var name = obj.parentNode.parentNode.childNodes[3];
	name.setAttribute("contenteditable","true");
	var phone = obj.parentNode.parentNode.childNodes[5];
	phone.setAttribute("contenteditable","true");
}